package com.dpj.yygh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dpj.yygh.mapper.HospitalSetMapper;
import com.dpj.yygh.model.hosp.HospitalSet;
import com.dpj.yygh.service.HospitalSetService;
import com.dpj.yygh.vo.hosp.HospitalSetQueryVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class HospitalSetServiceImpl extends ServiceImpl<HospitalSetMapper, HospitalSet> implements HospitalSetService {
    @Override
    public Page<HospitalSet> getPageHospSet(Long current, Long limit, HospitalSetQueryVo hospitalSetQueryVo) {
        Page<HospitalSet> page=new Page<>(current,limit);
        QueryWrapper<HospitalSet> queryWrapper=new QueryWrapper<>();
        String hoscode = hospitalSetQueryVo.getHoscode();
        String hosname = hospitalSetQueryVo.getHosname();
        if(!StringUtils.isEmpty(hoscode)){
            queryWrapper.like("hoscode",hoscode);
        }

        if(!StringUtils.isEmpty(hosname)){
            queryWrapper.like("hosname",hosname);
        }

        Page<HospitalSet> page1 = baseMapper.selectPage(page, queryWrapper);
        return page1;
    }
    //根据传递过来医院编码，查询数据库，查询签名
    @Override
    public String getSignKey(String hoscode) {
        QueryWrapper<HospitalSet> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("hoscode",hoscode);
        HospitalSet hospitalSet = baseMapper.selectOne(queryWrapper);
        return hospitalSet.getSignKey();
    }
}
